package com.qf.mapper;

import com.qf.entity.Student;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentMapper {
    //查询所有学生信息，以及每个学生对应的班级信息
    List<Student> selectAllStudentAndGrade();

    //查询所有学生信息，以及每个考生考了哪些科目
    List<Student> selectAllStudentAndSubject();

    List<Student> selectAll();//映射文件编写
    @Select("select * from student")
    List<Student> selectAllByAnno();//注解编写SQL语句

    @Select("select * from student where stuId = #{stuId}")
    Student selectByIdAndAnno(Integer stuId);//注解

    @Options(useGeneratedKeys = true,keyProperty = "stuId")
    @Insert("insert into student values(0,#{stuName},#{stuGender},#{stuPhone},#{bornDate},#{stuEmail},#{stuAddress},1)")
    int insert(Student student);

    @Select("select * from student where stuName = '${name}'")
    Student selectByStuName(@Param("name") String stuName);

    Student selectByStuId(Integer stuId);

    //查询所有的学生，并根据出生日期排序。  desc
    @Select("select * from student order by bornDate ${value}")
    List<Student> selectAllByOrders(String orders);

    //  根据用户的性别、地址、班级编号、用户姓名(模糊)
    List<Student> selectByCondition(Student student);

    int update(Student student);

    int deleteByStuIds(Integer[] stuIds);
}
